<template>

  <card-component
    :content-title="contentTitle"
    :page="page"
    @handleSizeChange="handleSizeChange"
    @handleCurrentChange="handleCurrentChange">


    <table-component slot="table"
                     :table-header="tableHeader"
                     :table-data="tableData"
                     :page="page"></table-component>


  </card-component>

</template>

<script>

  import card from '@/base/card.vue'
  import table from '@/base/AutoWidthTable.vue'
  import action from '@/base/action.vue'
  import request from '@/common/js/request'


  import util from '@/common/js/util'

  export default {
    components: {
      'card-component': card,
      'table-component': table,
      'action-componet': action,
    },
    data() {
      return {
        contentTitle: this.$getTextByLangKey("spi结果"),
        tableHeader: [],
        tableData: [],
        page: {
          currentPage: 1,
          total: 0,
          pageSize: 20,
        },
        filterParams:{

        }
      }
    },
    created: function () {
      this.fetchSpiDetailList()
    },

    destroyed: function () {

    },

    watch: {

    },

    methods: {
      // requestPcbaRecordList,
      // requestPcbaRecordExport,
      // requestScanRecordListHistory
      fetchSpiDetailList(){
        request.requestSpiDetailByPCBARecordId({page:this.page.currentPage,size:this.page.pageSize,pcbaRecordId:this.$route.query.pcbaRecordId},res=>{
          if(res.data.code === 200){
            const data = res.data.data
            this.tableHeader = this.makeHeader(data.headers)
              this.tableData = this.makeList(data.pageInfo.list)
          }
        })
      },

      makeHeader(headers){
        // let actionItem = {type: "action", label: this.$getTextByLangKey('操作'), isShow: true,width:'200px'}

        const newHeaders = headers?headers.map(x=>{
          x.isShow = true
          return x
        }):[]

        return newHeaders
      },

      makeList(list){
        const newList = list?list.map(x=>{
          x.createTime = new Date(x.createTime).format("yyyy/MM/dd hh:mm")
          return x
        }):[]
        return newList
      },


      handleSizeChange: function (val) {
        this.$emit("handleSizeChange", val)
      },
      handleCurrentChange: function (val) {
        this.page.currentPage = val
        this.fetchSpiDetailList()
      },


    },


  }
</script>


<style scoped>
  .el-card {
    box-shadow: 0 0;
    border-radius: 0;
    border: none;
  }
</style>


